const store = {
  get: function (key) {
    let str = localStorage.getItem(key);
    let json = null;
    if (!str) {
      return str;
    }
    try {
      json = JSON.parse(str);
    } catch (e) {
      console.log(e);
    }
    if (!json || typeof json != "object") {
      return str;
    }
    if (!json.data) {
      return json;
    }
    return json.data;
  },
  set: function (key, value) {
    let json = {
      time:new Date().valueOf(),
      data: value,
    };
    localStorage.setItem(key, JSON.stringify(json));
  },
  remove: function (key) {
    localStorage.removeItem(key);
  },
  clear: function () {
    localStorage.clear();
  },
};
